// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import {store} from './store/store.js'
import axios from 'axios'
import zcServer from './common/zcServer'
import zcAliFile from './common/zcAliFile'
import zcWin from './common/zcWin'

Vue.config.productionTip = false;

Vue.prototype.$ZcPublic = {
  Http: axios,
  Server: zcServer,
  AliUp: zcAliFile,
  Domain : zcServer.zcDomain,
  UserId: null,
  PersonSN: '',
  GB_OrganSN: '',
 	browserNew:null,
  zcWin:zcWin
}

var mainVue = new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
  created(){
  }
});
router.beforeEach((to, from, next) => {
  if (to.meta.needUserId) {
    if (Vue.prototype.$ZcPublic.UserId == '') {
      Vue.prototype.$ZcPublic.UserId = null;
      next({
        path: "/bsLogin",
        query: {redirect: from.fullPath}
      })
    } else {
      next()
    }
  }

  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    window.document.title = to.meta.title;
    next();
  }
  else {
    next();
  }
})
